/*
* @Author: lusx
* @Date: 2020-04-21 15:15:20
 * @Last Modified by: lusx
 * @Last Modified time: 2020-04-23 13:56:26
*/
import { Row, Col, Button } from 'antd';
import { WeaBrowser, WeaLocaleProvider, WeaTextarea } from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
let browserParam = {
    hasAddBtn: false,
    hasAdvanceSerach: true,
    idSeparator: ",",
    isAutoComplete: 1,
    isDetail: 0,
    isMultCheckbox: false,
    isSingle: true,
    linkUrl: "/hrm/resource/HrmResource.jsp?id=",
    pageSize: 10,
    quickSearchName: "",
    title: getLabel(383424, "人力资源"),
    type: "1",
    viewAttr: 1,
}
const Log = (item) => {
    return (
        <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@585rfz`} style={{ borderBottom: '1px solid #E2E2E2', marginTop: '20px' }}>
            <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@kyo7ui`} span="3">
                <img src={item.creater.imgurl} className="manager-img" style={{ marginLeft: "0px" }} />
            </Col>
            <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@aj4wv3`} span="21">
                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@jye39j`} className='exchange-row'>
                    <a href={'javaScript:openhrm(' + item.creater.id + ');'} onClick={e => window.pointerXY(e)} >
                        <span className='exchange-hrm'>{item.creater.name} : </span>
                    </a>
                    <span >{item.content}</span>
                </Row>
                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@r88fqe`} className='modify-log'>
                    {item.details && item.details.map((c, index) => {
                        const arrow = c.original ? '>' : ''
                        return <div className='modify-record' dangerouslySetInnerHTML={{ __html: "<span style='font-weight:lighter'>" + c.fieldname + "</span>" + '&nbsp;&nbsp;&nbsp;' + "<span class='log-red'>" + c.original + "</span>" + arrow + "<span class='log-green'>" + c.modified + "</span>" }}></div>;
                    })}
                </Row>
                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@qt4kmt`} className='exchange-row'>
                    <span className='exchange-date'>{item.time}</span>
                </Row>
            </Col>
        </Row>
    )

}
const Daily = (props) => {
    const { item, showReply, submitType, setReply, huifuHandle, shanchuHandle, bianjiHandle, tijiaoHandle } = props;
    return (
        <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@96tgeo`} style={{ borderBottom: '1px solid #E2E2E2', marginTop: '20px' }}>
            <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@73b45j`} span="3">
                <img src={item.creater.imgurl} className="manager-img" style={{ marginLeft: "0px" }} />
            </Col>
            <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@31yw6b`} span="21">
                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@5kh7sk`} className='exchange-row'>
                    <a href={'javaScript:openhrm(' + item.creater.id + ');'} onClick={e => window.pointerXY(e)} >
                        <span className='exchange-hrm'>{item.creater.name}:&nbsp;&nbsp;</span>
                    </a>
                    <span dangerouslySetInnerHTML={{ __html: item.content }}></span>
                </Row>
                <span className='exchange-date'>{item.createdate + ' ' + item.createtime}</span>
                <span style={{ float: 'right' }}>
                    <span className='exchange-operate' onClick={() => shanchuHandle()}><a>删除</a>
                    </span>
                    <span className='exchange-operate' onClick={() => bianjiHandle()}><a>编辑</a>
                    </span>
                    <span className='exchange-operate' onClick={() => huifuHandle(item)}><a>{getLabel('128123', '回复')}</a>
                    </span>
                </span>
                {
                    item.replys && item.replys.map((item, index) => {
                        return <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@6wlbaw@${index}`} style={{ padding: 0 }}>
                            <div style={{ padding: 0 }}>
                                <span className='exchange-hrm'>
                                    <a href={'javaScript:openhrm(' + item.creater.id + ');'} onClick={e => window.pointerXY(e)} >
                                        <span className='exchange-hrm'>{item.creater.name}&nbsp;&nbsp;</span>
                                    </a>
                                </span>
                                <span className='exchange-date'>{item.createdate + ' ' + item.createtime}</span>
                            </div>
                            <span dangerouslySetInnerHTML={{ __html: getLabel('128123', '回复') + '：' + item.content }}></span>
                        </Row>
                    })
                }
                {showReply[item.id] && <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@yzz32o`} style={{ padding: 0 }}>
                    <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@k32je0`} style={{ padding: 0 }}>
                        <WeaTextarea ecId={`${this && this.props && this.props.ecId || ''}_WeaTextarea@hjsaiz`} viewAttr={2} onChange={(v) => { setReply(v) }} />
                    </Row>
                    <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@vi74o5`} style={{ padding: '5px 0' }}>
                        <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@waejew`} key="submit" type="primary" size="small" style={{ display: 'inline-block', borderRadius: '3px', float: 'right' }} onClick={() => tijiaoHandle(showReply, item, submitType)} >{getLabel(383336, "提交")}</Button>
                    </Row>
                </Row>}
            </Col>
        </Row>
    )
}
const JlChild = (props) => {
    const { element, replaceDatas, sortid, wf_auth_url, doc_auth_url, acc_auth_url } = props;
    return (
        <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@dcwai9`}>
            <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@cyrjp6`} span={3}>
                <img className="manager-img" src={`${element.creater.imgurl}`} style={{ borderRadius: '20px' }} />
            </Col>
            <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@1jkh26`} span={21}>
                <div className="jiaoliu-box">
                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@ogutyy`} {...browserParam} replaceDatas={replaceDatas} style={{ display: 'inline-block' }} />:&nbsp;&nbsp;
                <span dangerouslySetInnerHTML={{ __html: element.remark }} />
                    {
                        element.projectids.length > 0 ?
                            element.projectids.map((e, _index) => {//相关项目
                                return <div>
                                    <span className="icon-blog-Project" style={{ paddingRight: '5px' }} />
                                    <a href='javascript:void(0)' linkid={e.id} linkType='workflow' onClick={() => openProjectAppLink('project',
                                        e.id, sortid)} ondblclick={() => false}
                                        unselectable='off' contenteditable='false'
                                        style={{ cursor: 'pointer', textDecoration: 'underline !important', marginRight: '8px' }}>{e.name} </a>
                                </div>
                            }) : ''
                    }
                    {
                        element.relatedcus.length > 0 ?
                            element.relatedcus.map((e, _index) => {//客户
                                return <div>
                                    <span className="icon-blog-Personnel" style={{ paddingRight: '5px' }} />
                                    <a href='javascript:void(0)' linkid={e.id} linkType='workflow' onClick={() => openProjectAppLink('crm', e.id,
                                        sortid)} ondblclick={() => false}
                                        unselectable='off' contenteditable='false'
                                        style={{ cursor: 'pointer', textDecoration: 'underline !important', marginRight: '8px' }}>{e.name} </a>
                                </div>
                            }) : ''
                    }
                    {
                        element.relateddoc.length > 0 ?
                            element.relateddoc.map((e, _index) => {//修改成附件
                                if (e.showLoad) {
                                    return <div>
                                        <span className="icon-blog-Enclosure" style={{ paddingRight: '5px' }} />
                                        <a onClick={() => openProjectDiscussDoc(this, e.fileid, sortid, acc_auth_url)} href='javascript:void(0);'
                                            unselectable='off' contenteditable='false'
                                            style={{ cursor: 'pointer', textDecoration: 'underline !important', marginRight: '8px' }}>{e.filename}</a>
                                        <a unselectable='off' contenteditable='false' href={e.loadlink} target='_blank'
                                            style={{ cursor: 'pointer', textDecoration: 'underline !important', marginRight: '8px' }}>{`${getLabel(258,
                                                "下载")}(${e.filesize})`}</a>
                                    </div>
                                } else {
                                    return <div>
                                        <span className="icon-blog-Enclosure" style={{ paddingRight: '5px' }} />
                                        <a onClick={() => openProjectDiscussDoc(this, e.fileid, sortid, acc_auth_url)} href='javascript:void(0);'
                                            unselectable='off' contenteditable='false'
                                            style={{ cursor: 'pointer', textDecoration: 'underline !important', marginRight: '8px' }}>{e.filename}</a>
                                    </div>
                                }
                            }) : ''
                    }
                    {
                        element.relatedprj.length > 0 ?
                            element.relatedprj.map((e, _index) => {
                                return <div>
                                    <span className="icon-blog-Task" style={{ paddingRight: '5px' }} />
                                    <a href='javascript:void(0)' linkid={e.id} linkType='workflow' onClick={() => openProjectAppLink('task',
                                        e.id, sortid)} ondblclick={() => false}
                                        unselectable='off' contenteditable='false'
                                        style={{ cursor: 'pointer', textDecoration: 'underline !important', marginRight: '8px' }}>{e.name} </a>
                                </div>
                            }) : ''
                    }
                    {
                        element.relatedwf.length > 0 ?
                            element.relatedwf.map((e, _index) => {//流程
                                return <div>
                                    <span className="icon-blog-Process" style={{ paddingRight: '5px' }} />
                                    <a href='javascript:void(0)' linkid={e.id} linkType='workflow' onClick={() => openProjectAppLink('workflow',
                                        e.id, sortid, wf_auth_url)} ondblclick={() => false}
                                        unselectable='off' contenteditable='false'
                                        style={{ cursor: 'pointer', textDecoration: 'underline !important', marginRight: '8px' }}>{e.name} </a>
                                </div>
                            }) : ''
                    }
                    {
                        element.docids.length > 0 ?
                            element.docids.map((e, _index) => {//文档
                                return <div>
                                    <span className="icon-blog-Document" style={{ paddingRight: '5px' }} />
                                    <a href='javascript:void(0)' linkid={e.id} linkType='workflow' onClick={() => openProjectAppLink('doc', e.id,
                                        sortid, doc_auth_url)} ondblclick={() => false}
                                        unselectable='off' contenteditable='false'
                                        style={{ cursor: 'pointer', textDecoration: 'underline !important', marginRight: '8px' }}>{e.name} </a>
                                </div>
                            }) : ''
                    }
                </div>
            </Col>
        </Row>
    )
};
const jlParamsHandle = (_exchangeList) => {
    let bottomBarConfig = [];
    let mirror = {
        Document: { type: 37, name: getLabel(126529, "文档"), icon: 'icon-blog-Document' },
        Flow: { type: 152, name: getLabel(131692, "流程"), icon: 'icon-blog-Process' },
        Customer: { type: 18, name: getLabel(30043, "客户"), icon: 'icon-blog-Personnel' },
        Project: { type: 135, name: getLabel(30046, "项目"), icon: 'icon-blog-Project' },
        Task: { type: 'prjtsk', name: getLabel(383349, "任务"), icon: 'icon-blog-Task' },
    }
    let objDocument = {
        name: 'Browser',
        show: <div className="wea-cb-item">
            <span className={`wea-cbi-icon ${mirror['Document'].icon}`} />
            <span className="wea-cbi-text">{mirror['Document'].name}</span>
        </div>,
        type: mirror['Document'].type,
        title: mirror['Document'].name,
    };
    let objFlow = {
        name: 'Browser',
        show: <div className="wea-cb-item">
            <span className={`wea-cbi-icon ${mirror['Flow'].icon}`} />
            <span className="wea-cbi-text">{mirror['Flow'].name}</span>
        </div>,
        type: mirror['Flow'].type,
        title: mirror['Flow'].name,
    };
    let objCustomer = {
        name: 'Browser',
        show: <div className="wea-cb-item">
            <span className={`wea-cbi-icon ${mirror['Customer'].icon}`} />
            <span className="wea-cbi-text">{mirror['Customer'].name}</span>
        </div>,
        type: mirror['Customer'].type,
        title: mirror['Customer'].name,
    };

    let objProject = {
        name: 'Browser',
        show: <div className="wea-cb-item">
            <span className={`wea-cbi-icon ${mirror['Project'].icon}`} />
            <span className="wea-cbi-text">{mirror['Project'].name}</span>
        </div>,
        type: mirror['Project'].type,
        title: mirror['Project'].name,
    };
    let objTask = {
        name: 'Browser',
        show: <div className="wea-cb-item">
            <span className={`wea-cbi-icon ${mirror['Task'].icon}`} />
            <span className="wea-cbi-text">{mirror['Task'].name}</span>
        </div>,
        type: mirror['Task'].type,
        title: mirror['Task'].name,
    };

    _exchangeList.docids && bottomBarConfig.push(objDocument);//相关文档
    _exchangeList.relatedwf && bottomBarConfig.push(objFlow);//相关流程
    _exchangeList.relatedcus && bottomBarConfig.push(objCustomer);//相关客户
    _exchangeList.projectids && bottomBarConfig.push(objProject);//相关项目
    _exchangeList.relatedprj && bottomBarConfig.push(objTask);//相关任务
    _exchangeList.relateddoc && bottomBarConfig.push({
        name: 'Upload',
        show: <div className="wea-cb-item">
            <span className='wea-cbi-icon icon-blog-Enclosure' />
            <span className="wea-cbi-text">{getLabel(128158, "附件")}</span>
        </div>,
        uploadId: 'project_edit',
        uploadUrl: `${_exchangeList.relateddoc.uploadUrl}?category=${_exchangeList.relateddoc.category}`,
        category: _exchangeList.relateddoc.category,
        maxUploadSize: _exchangeList.relateddoc.maxSize,
        style: { display: "inline-block", padding: 0 }
    })
    return bottomBarConfig;
}
export { JlChild, jlParamsHandle, Daily, Log };